import axios from "axios"
import store from "../store/store"
//创建axios实例
var Axios = axios.create({
  baseURL: 'http://localhost:8888/api/private/v1/',
  timeout: 10000,
})
// 请求拦截器,发起请求,打开loading
Axios.interceptors.request.use((config) => {
  if (store.state.token) {
    config.headers.Authorization = store.state.token
  }
  return config;
}, (err) => {
  return Promise.reject(err)

})
//响应拦截器,响应回来关闭loading
Axios.interceptors.response.use((response) => {
  return response;
}
  , (err) => {
    return Promise.reject(err);
  }
)
export default Axios;